/*
 * CS_CHANGE_TUTORIAL_STATE.cpp
 *
 *  Created on: 2013. 8. 26.
 *      Author: jjaehuny
 */

#include "Tutorial.h"
#include "../../../constant.h"
#include "../../../User.h"


namespace ProjectZ { namespace NCommand { namespace NWorld { namespace NTutorial {


// 이미 케릭터 정보를 받은 후에 그 케릭터에 튜토리얼 정보를 요청하는 패킷
void CS_CHANGE_TUTORIAL_STATE::OnExecute(User * pUser, ::Network::Packet * pPacket)
{
	PREPARE_PACKET;

	/* Message 정의
		CS_CHANGE_TUTORIAL_STATE			0x094A
		{
			u8 u8slot_seq;
			u8 u8question_list_idx;	/// 상태 변경할 인덱스 0부터
			u8 u8state;				/// 0 : 비노출 1: 노출 2: 완료
		}
	 */

	uint8_t u8slot_seq;
	uint8_t u8question_list_idx;
	uint8_t u8state;
	* pPacket >> u8slot_seq >> u8question_list_idx >> u8state;

	::Network::Packet * pAck = ::Network::GETPACKETPOOL()->SEND_NEW();
	if (4 <= u8question_list_idx || u8question_list_idx < 0)
	{
		* pAck << static_cast<uint16_t>(0);
		pAck->MakePacket(CMD_SC_CHANGE_TUTORIAL_STATE);
		pUser->Send(pAck);
		return;
	}

	pUser->GetUserInfo().array_tutorial[u8question_list_idx] = u8state;

	DEBUGLOG("CS_CHANGE_TUTORIAL_STATE u8question_list_idx : %d, u8state : %d", u8question_list_idx, u8state);

	pUser->FlushUserInfoCache();
	pUser->FlushCharacterInfoCache();

	* pAck << static_cast<uint16_t>(1);
	pAck->MakePacket(CMD_SC_CHANGE_TUTORIAL_STATE);
	pUser->Send(pAck);
}

} /*NTutorial*/ } /*NWorld*/ } /*NCommand*/ } /*ProjectZ*/

